/*
 * @Author: Bboy大蛇 2951845438@qq.com
 * @Date: 2024-07-21 20:09:39
 * @LastEditors: Bboy大蛇 2951845438@qq.com
 * @LastEditTime: 2024-08-27 10:02:08
 * @FilePath: \MyProject_3D\assets\script\src\Game\Menu\MenuPanel.ts
 */
import { _decorator, Node, PageView } from 'cc';
import { LayerType } from '../../Basic/Config/BaseEnum';
import { PanelBase } from '../../Basic/UI/PanelBase';
import { MenuModel } from './MenuModel';
// import { GameModel } from '../Game/GameModel';
// import { DataMgr } from '../../Basic/Manager/DataManager';
// import { GameParams } from '../../Basic/Config/DataConfig';
// import { EnergyModel } from '../Dialog/EnergyModel';
import { LevelModel } from '../Level/LevelModel';

const { ccclass, property } = _decorator;

@ccclass('MenuPanel')
export class MenuPanel extends PanelBase {
  @property(PageView)
  mainPageView: PageView;

  @property(Node)
  bottomBtnList: Node;

  panelLayer: LayerType.MenuLayer = LayerType.MenuLayer;

  protected onEnable(): void {
    super.onEnable();
    MenuModel.Ins().mainNode = this.node;
    MenuModel.Ins().mainPageView = this.mainPageView;
    // MenuModel.Ins().initPageView();
  }

  protected start(): void {}

  /** 切换页面 */
  onChangePage(t: Touch, data) {
    if (data === null || data === '') return;
    // const num = Number(data);
    // MenuModel.Ins().changePage(num);
  }

  /** 点击开始游戏 */
  onClickStart() {
    this.closeSelf();
    // GameModel.Ins().Show();
    LevelModel.Ins().Show();
    // if (DataMgr.gameParams.get(GameParams.energy_award) >= 3) {
    //   this.closeSelf();
    //   // GameModel.Ins().Show();
    //   LevelModel.Ins().Show();
    // } else if (DataMgr.gameParams.get(GameParams.energy) <= 0) {
    //   EnergyModel.Ins().Show();
    // } else {
    //   EnergyModel.Ins().useEnergy(1);
    //   this.closeSelf();
    //   // GameModel.Ins().Show();
    //   LevelModel.Ins().Show();
    // }
  }

  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  onClick(event, val) {
    // switch (val) {
    //   case '1':
    //     testModel1.Ins().Show();
    //     break;
    //   case '2':
    //     testModel2.Ins().Show();
    //     break;
    //   case '3':
    //     testModel3.Ins().Show();
    //     break;
    // }
  }
}
